import NProgress from "nprogress";
import "nprogress/nprogress.css";

//关闭顶部右侧的旋转加载
NProgress.configure({showSpinner: false});

import {createRouter, createWebHistory} from 'vue-router'


const routes = [
    {
        path: '/',
        name: "index",
        component: () => import('@/layout/index.vue'),
        // redirect: "/index",
        children: [
            // {
            //     path: "/index",
            //     name: "Index",
            //     component: () => import('@/layout/main/index.vue'),
            //     meta: {
            //         title: '系统首页'
            //     },
            // }
        ]
    },
    {
        path: '/test',
        name: "test",
        component: () => import('@/layout/test.vue'),
    },
]

const router = createRouter({
    history: createWebHistory(),
    routes,
})


router.beforeEach(async (to, from, next) => {

    NProgress.start();

    next();

})

router.afterEach((to, from, failure) => {
    if (to.meta?.title) {
        document.title = to.meta.title;
    }
    NProgress.done();
})

export default router;

